package com.ys.mapper;

import com.ys.config.ApplicationConfig;
import com.ys.pojo.As;
import com.ys.pojo.Asa;
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.annotation.Resource;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.ArrayList;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = ApplicationConfig.class)
public class Texts {
    @Resource
    private MenuMapper menuMapper;
    @Test
    public void te(){
//        menuMapper.findBySelect().forEach(x->{
//            System.out.println(x.getGname());
//        });

        List<As> list = new ArrayList<>();
        menuMapper.findByAdminAndPwd("admin","admin").forEach(x->{
            As as  = new As();
            as.setName(x.getGname());
            System.out.println(x.getGname());
            List<Asa> asas = new ArrayList<>();
            menuMapper.findByAdminAndPwds("admin","admin",x.getId()).forEach(a->{
                asas.add(new Asa(a.getGname(),a.getIcons(),a.getUrl(),a.getId()));
//                System.out.println(a.getGname()+"---"+a.getUrl());
            });
            as.setAsa(asas);
            list.add(as);
        });

        list.forEach(x->{
            System.out.println(x.getName());
            x.getAsa().forEach(a->{
                System.out.println(a.getNames()+"--"+a.getUrls()+"---"+a.getIds()+"============="+a.getIcon());
            });
        });
    }

    @Test
    public void ce(){
        Duanxin1 duanxin = new Duanxin1();
    }
}
